﻿//------------------------------------------------------------------------------
// System Name:    Customer Service Platform
// Component:      CCS PCATInDepHelper
// Created By:     Samara Jiang (samaraj@wicresoft.com)
// Created Date:   2011-3-15
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;
using ASBCC.Database.EntityFramework;

namespace ASB.CC.Business.CCS
{
    /// <summary>
    /// CCS Department分模块枚举
    /// </summary>
    public enum DepartmentModule
    {
        AB,
        CD,
        EF,
        GH,
        IJ,
        KL,
        MN,
        OP,
        QR,
        ST,
        UV,
        WX,
        YZ,
    }

    public static class PCATInDepHelper
    {
       
        public static void InternalUpdateProvince(ObjectContext dc, Province province, string departmentList)
        {
            if (departmentList != null)
            {
                var departments = dc.CreateQuery<Department>("[Departments]");
                foreach (var department in departmentList.Split(','))
                {
                    int departmentID = int.Parse(department);
                    var entity = departments.First(p => p.DepartmentID == departmentID);
                    province.Departments.Add(entity);
                }
            }

        }

        public static void InternalUpdateCAT(ObjectContext dc, Category cat, string departmentList)
        {
            if (departmentList != null)
            {
                var departments = dc.CreateQuery<Department>("[Departments]");
                foreach (var department in departmentList.Split(','))
                {
                    int departmentID = int.Parse(department);
                    var entity = departments.First(p => p.DepartmentID == departmentID);
                    cat.Departments.Add(entity);
                }
            }

        }


    }
}
